<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Product media data template
 *
 * @see Mage_Catalog_Block_Product_View_Media
 */
?>

<!-- Fetch product-image information -->
<?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
?>

<!-- Check if Base image is defined, and if so, display it with Highslide effect -->
<?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>

<div class="highslide-gallery">
    <a href="<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>" class="highslide" onclick="return hs.expand(this)">
        <img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(265) ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel()) ?>"
            title="Click to enlarge" />
    </a>
    <!-- Add caption below the image -->
    <div class="highslide-caption">
        <?php echo $this->htmlEscape($this->getImageLabel()) ?>
    </div>
</div>

<!-- No Base image available. Will show default image from Magento -->
<?php else: ?>
    <?php
        $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($_product->getImageLabel()).'" />';
        echo $_helper->productAttribute($_product, $_img, 'image')
    ?>
<?php endif; ?>

<!-- Hey, this product has more images so we'll display the gallery and Highslide them as well -->
<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
    <div class="highslide-gallery">
    <h4><?php echo $this->__('More Views') ?></h4>
    <ul>
    <?php foreach ($this->getGalleryImages() as $_image): ?> 
        <li>
            <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" class="highslide" onclick="return hs.expand(this)">
            <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>       
        <div class="highslide-caption">
            <?php echo $this->htmlEscape($_image->getLabel()) ?>
        </div>           
       </li>
    <?php endforeach; ?>  
    </ul>
    </div>
</div>

<?php endif; ?>

<!-- End of media.phtml with Highslide-effect -->